package com.czc.qinglong.controller;


import com.czc.qinglong.domain.EnvironmentDO;
import com.czc.qinglong.service.QingLongService;
import com.czc.qinglong.util.ResultData;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;


@RestController
@RequestMapping("/qinglong")
public class qinglongController {
    @Resource
    private QingLongService qingLongService;


    /*/
    添加环境变量
     */
    @PostMapping("addEnvironment")
    public ResultData addEnvironment(@RequestBody EnvironmentDO environmentDO) throws IOException {
        return qingLongService.addEnvironment(environmentDO);
    }

    /*/
    定时任务删除失效的环境变量,设置为每天凌晨一点，每天一点执行一次
     */
    @Scheduled(cron = "0 0 1 * * ? ")
    public void deleteInvialdEnvironment() {
        qingLongService.deleteInvialdEnvironment();
    }

}
